$(function(){
    $.getJSON('index/catalog.json', function (data) {
        let catalogAll = data
        console.log(data)
        $('.header_main_left_a').each(function(){
            let catalogNums = $(this).attr('ctg-data')
            if(catalogNums){
                let panel = $('<div class="header_main_left_main"></div>')
                let panelol = $('<ol class="header_ol"></ol>')
                let  catalogNumArray = catalogNums.split(',')
                $.each(catalogNumArray, function (i, catalog1Id) {
                    let catalog2List= catalogAll[catalog1Id]
                    $.each(catalog2List, function (i, catalog2) {
                        let catalog2Link = $('<a href="#" class="aaa">' + catalog2.name + '</a>')
                        let li = $('<li></li>')
                        let catalog3List = catalog2['catalog3List']
                        let len = 0
                        $.each(catalog3List, function (i, catalog3) {
                            let catalog3Link = $('<a href="http://search.yomall.com/list.html?catalog3Id='+catalog3.id+'">'+catalog3.name+'</a>')
                            li.append(catalog3Link)
                            len = len + 1 + catalog3.name.length
                        })
                        if(len >= 46 && len < 92){
                            li.attr('style','height: 60px;')
                        }else if(len >= 92){
                            li.attr('style', 'height: 90px;')
                        }
                        panelol.append(catalog2Link).append(li)
                    })
                })
                panel.append(panelol)
                $(this).after(panel)
                $(this).parent().addClass('header_li2')
            }
        })
    })
})